﻿using Besture.Bll;
using Besture.Common;
using Besture.UI.ClassHelper;
using DevExpress.Web.ASPxGridView;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Besture.UI.Admin.UserBase
{
    public partial class DealerCheckUserBaseList : BasePage
    {
        #region 页面加载

        /// <summary>
        /// 初始化页面
        /// </summary>
        protected override void InitialLoad()
        {
            //初始化页面
            InitPage();
            BindData();
            AspxGridViewHelper.InitAspxGridView(grid);
        }

        /// <summary>
        /// 回发
        /// </summary>
        protected override void PostBackLoad()
        {
            BindData();
        }

        /// <summary>
        /// 初始化页面
        /// </summary>
        public void InitPage()
        {

        }

        /// <summary>
        /// 审核  选中数据
        /// </summary>
        public void DeleteSelect(int iCheckStatus)
        {
            string ids = AspxGridViewHelper.GetCheckID(grid);
            if (string.IsNullOrEmpty(ids))
            {
                return;
            }
            UserBaseDac partDac = new UserBaseDac();
            partDac.DeleteList(AdminUserService.AdminLoginUser.ID, iCheckStatus, ids);
            BindData();
        }

        /// <summary>
        /// 绑定数据
        /// </summary>
        public void BindData()
        {
            var dac = new UserBaseDac();
            grid.DataSource = dac.GetDataTableByUserType(Constants.USER_TYPE_DISTRIBUTOR);
            grid.DataBind();
        }

        /// <summary>
        /// AspxGridView回发事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void GridCustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
        {
            if (e.Parameters == "Refresh")
                grid.DataBind();
        }
        #endregion


        /// <summary>
        /// 审核通过
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="eventArgs"></param>
        protected void lbAdd_Click(object obj, EventArgs eventArgs)
        {
            //0 审核中 1 已审核 2 取消审核
            DeleteSelect(1);
        }

        /// <summary>
        /// 审核通过
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="eventArgs"></param>
        protected void lbClear_Click(object obj, EventArgs eventArgs)
        {
            //0 审核中 1 已审核 2 取消审核
            DeleteSelect(2);
        }
    }
}